package cn.zc.service.impl;

import cn.zc.entity.Cource;
import cn.zc.entity.CourceSQL;
import cn.zc.entity.LateTimeCource;
import cn.zc.entity.User;
import cn.zc.mapper.AdminMapper;
import cn.zc.mapper.CourceMapper;
import cn.zc.service.CourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

@Service
public class CourceServiceImpl implements CourceService {
    @Autowired
    private CourceMapper courceMapper;
    @Autowired
    private AdminMapper adminMapper;
    //查看当前是第几周
    public int getNowWeek() {
        return courceMapper.getWeek();
    }
    /**
     * 添加学生的课表到数据库
     * @param cources
     * @param
     */
    @Override
    public void insertStudentCourse(List<CourceSQL> cources) {
        courceMapper.insertStudentCourse(cources);
    }

    @Override
    public void lateTime(int period, int dayOfWeekValue) {
        courceMapper.lateTime(period, dayOfWeekValue);
    }
    @Override
    public List<LateTimeCource> selectlateTime(int period, int dayOfWeekValue) {
        List<LateTimeCource> lateTimeCources = courceMapper.selectlateTime(period, dayOfWeekValue);
        return lateTimeCources;
    }
    @Override
    public void addLateTimeCource(LateTimeCource lateTimeCource) {
        courceMapper.addLateTimeCource(lateTimeCource);
    }

    @Override
    public List<CourceSQL> getcourcevoByid(String id) {
        return courceMapper.getcourcevoByid(id);
    }

    @Override
    public void updateIsOver() {
        //查询都有哪些用户
        List<User> adminInfo = adminMapper.getUserInfo();
        //遍历用户，更新每一个用户的isover
        for (User user : adminInfo) {
            List<CourceSQL> courceList = courceMapper.getCourceByUserId(user.getId());

            for (CourceSQL cource : courceList) {

            }
        }
        courceMapper.updateIsOver();
    }
}

